//
//  Extension+UIButton.swift
//  Weibo
//
//  Created by mac on 15/12/17.
//  Copyright © 2015年 MK. All rights reserved.
//

import UIKit

extension UIButton {
    
    convenience init(imageName: String, titleColor: UIColor, titleName: String, titleFont: CGFloat, isnothighLight: Bool = false) {
        
        //self.init() 首先初始化自己本类UIButton
        self.init()
        
        if isnothighLight == false {
            setBackgroundImage(UIImage(named: imageName), forState: .Normal)
            setBackgroundImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        }
        
        if isnothighLight == true {
            setImage(UIImage(named: imageName), forState: .Normal)
        }
        
        setTitleColor(titleColor, forState: .Normal)
        setTitle(titleName, forState: UIControlState.Normal)
        titleLabel?.font = UIFont.systemFontOfSize(titleFont)
        
        sizeToFit()
    }
    
    
}



extension UIButton {
    
    convenience init(imageName: String, backImageName: String) {
        
        self.init()
        
        setImage(UIImage(named: imageName), forState: .Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
        setBackgroundImage(UIImage(named: backImageName), forState: .Normal)
        setBackgroundImage(UIImage(named: backImageName + "_highlighted"), forState: .Highlighted)
        sizeToFit()
    }
    
    
}